<?php
namespace App\Http\Controllers\Admin;

use App\admin\Adlog;
use App\admin\About;
use App\admin\Logo;
use App\Http\Controllers\Admin\LogHander;
use App\Http\Controllers\Controller;
use App\Http\Middleware;
use Illuminate\Http\Request;
use Intervention\Image\ImageManagerStatic as Image;
use Illuminate\Routing\Controller as BaseController;

class ComPushController extends BaseController
{
	public function __construct() {
		$this->middleware('admindo');
	}
	//公司视频
	public function vido(){
		
		return view('admin.compushvide');
	}
	//公众号Logo
	public function Logo(Request $request){
		$id = $request->input('id');
		$Newnet = new Newnet;
		$back = $Newnet::find($id);
		return view('admin.compushlogo');
	}
	public function LogoUp(Request $request){
		$id = $request->input('id');
		$Logo = new Logo;
		$data = $Logo::find($id);
		$data->name = "微信公众号";
		if ($request -> hasFile('file')) {
			$file = $request -> file('file');
			$entension = $file -> getClientOriginalExtension();
			$ents = array("jpg", "jpge", "png", "bmp","gif");
			if(!in_array($entension, $ents)){
				return "只支持jpg, jpge, png, bmp,gif类型的图片";
			}
			$name = date("Ymd").str_random(10) . '.'.$entension;
			$path = public_path() .'/upload/qcode/'. $name;
			Image::make($file) -> save($path);
			$pathBase = 'upload/qcode/'. $name;
			$data->imgurl = $pathBase;
		}
		if($data->save()){
			return redirect('Logo'."?id=".$id);
		}
	}
	//分享应用
	public function Applicatoin(){
		
		return view('admin.compushapplication');
	}
}